package core;

import java.util.Iterator;
import java.util.LinkedList;


public class Path {
	private double bottleneck = Double.MAX_VALUE;
	public LinkedList<Edge> edgeList = new LinkedList<Edge>();
	public LinkedList<Vertex> vertexList = new LinkedList<Vertex>();
	
	public double getBottleneck() {
		if(bottleneck == Double.MAX_VALUE){
			Iterator<Edge> edgesIterator = getEdges().iterator();
			while(edgesIterator.hasNext()){
				bottleneck = Math.min(bottleneck, (Double)edgesIterator.next().getData());
			}
		}
		return bottleneck;
	}

	public void setBottleneck(double bottleneck) {
		this.bottleneck = bottleneck;
	}

	public LinkedList<Edge> getEdges() {
		return edgeList;
	}

	public void setEdges(LinkedList<Edge> edges) {
		this.edgeList = edges;
	}
	
	public void add(Edge edge){
		getEdges().add(edge);
	}
	
	public int size(){
		return getEdges().size();
	}
	
	@Override
	public String toString(){
		Iterator<Edge> edgesIterator = getEdges().iterator();
		Edge edge = edgesIterator.next();
		String path = edge.getFirstEndpoint().getName() + " =="+ edge.getData() + "==> " + edge.getSecondEndpoint().getName();
		while(edgesIterator.hasNext()){
			edge = edgesIterator.next();
			path = path + " =="+ edge.getData()+"==> " + edge.getSecondEndpoint().getName();
		}
		return path;
	}
}
